package com.pomr.model.health;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;

import com.pomr.model.menu.Relation;

/**
 * 家庭关系表
 * @author Administrator
 *
 */
@Entity
@Table(name="family_relation")
public class FamilyRelation implements Serializable{
	

	public Integer getFamilyrecord_id() {
		return familyrecord_id;
	}

	public void setFamilyrecord_id(Integer familyrecord_id) {
		this.familyrecord_id = familyrecord_id;
	}

	public String getRelationName() {
		return relationName;
	}

	public void setRelationName(String relationName) {
		this.relationName = relationName;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public PersonRecord getPersonrecord() {
		return personrecord;
	}

	public void setPersonrecord(PersonRecord personrecord) {
		this.personrecord = personrecord;
	}

	public Relation getRelation() {
		return relation;
	}

	public void setRelation(Relation relation) {
		this.relation = relation;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
    @GenericGenerator(name = "native", strategy = "native")//AUTO 在mysql中需要指定使用本地策略生成主键值
	private Integer id;
	
	@OneToOne(fetch = FetchType.LAZY,targetEntity = PersonRecord.class)
	@JoinColumn(name = "personrecord_id")
	private PersonRecord personrecord;//个人档案 单项一对一
	@Formula("(select c.name from person_record c where c.id=personrecord_id)")
	private String recordName;
	@Column(name="familyrecord_id")
	private Integer familyrecord_id;//家庭档案 编号
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="relation_id") 
	private Relation relation;//家庭角色
	
	@Formula("(select c.name from menu_relation c where c.id=relation_id)")
	private String relationName;//家庭角色名

}
